var currentIndexTemp = 0;
var indexTemp = 0;
efform_onload = function (){
	//模块进入时置查询条件为：当前年、月
	var d=new Date();
	var year=d.getFullYear();
	var month=d.getMonth()+1;
	$('#inqu_status-0-fdYear').val(year);
	$('#inqu_status-0-fdMonth')[0].options[month].selected = true;
	button_query_onclick();
}; 
button_query_onclick = function () 
{   	
	fundiv(currentIndexTemp,indexTemp);
//	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCN50","query");
	var info=new EiInfo();
	info.set("fdCurrentDate",getCurrentDate());//置当前日期
	EiCommunicator.send("ZMCN50", "query", info, CN50_callback); 
}

function fundiv(currentIndex,index){ 
	currentIndexTemp = currentIndex;
	indexTemp = index;
    var year=$("#inqu_status-0-fdYear").val();
	var month=$("#inqu_status-0-fdMonth").val();
	var fdDepartmentId=$("#inqu_status-0-fdDepartmentId").val();
	if(index ==0)
	{  
		var frame = frames[0];
		frame.src = "DispatchAction.do?efFormEname=ZMCN51"+"&fdYear="+year+"&fdMonth="+month+"&fdDepartmentId="+fdDepartmentId;
		efform.setStatus(0, "正在加载...");
	}else if(index ==1)
	{ 
		var frame = frames[1];
		frame.src = "DispatchAction.do?efFormEname=ZMCN52"+"&fdYear="+year+"&fdMonth="+month+"&fdDepartmentId="+fdDepartmentId;
		efform.setStatus(0, "正在加载...");
	}
	else if(index ==2)
	{ 
		var frame = frames[2];
		frame.src = "DispatchAction.do?efFormEname=ZMCN53"+"&fdYear="+year+"&fdMonth="+month+"&fdDepartmentId="+fdDepartmentId;
		efform.setStatus(0, "正在加载...");
	}
	else if(index ==3)
	{ 
		var frame = frames[3];
		frame.src = "DispatchAction.do?efFormEname=ZMCN54"+"&fdYear="+year+"&fdMonth="+month+"&fdDepartmentId="+fdDepartmentId;
		efform.setStatus(0, "正在加载...");
	}
	else if(index ==4)
	{ 
		var frame = frames[4];
		frame.src = "DispatchAction.do?efFormEname=ZMCN55"+"&fdYear="+year+"&fdMonth="+month+"&fdDepartmentId="+fdDepartmentId;
		efform.setStatus(0, "正在加载...");
	}
	else if(index ==5)
	{
		var frame = frames[5];
		frame.src = "DispatchAction.do?efFormEname=ZMCN56"+"&fdYear="+year+"&fdMonth="+month+"&fdDepartmentId="+fdDepartmentId;
		efform.setStatus(0, "正在加载...");
	}
	else if(index ==6)
	{ 
		var frame = frames[6];
		frame.src = "DispatchAction.do?efFormEname=ZMCN57"+"&fdYear="+year+"&fdMonth="+month+"&fdDepartmentId="+fdDepartmentId;
		efform.setStatus(0, "正在加载...");
	}
	else if(index ==7)
	{ 
		var frame = frames[7];
		frame.src = "DispatchAction.do?efFormEname=ZMCN58"+"&fdYear="+year+"&fdMonth="+month+"&fdDepartmentId="+fdDepartmentId;
		efform.setStatus(0, "正在加载...");
	}
	else if(index ==8)
	{ 
		var frame = frames[8];
		frame.src = "DispatchAction.do?efFormEname=ZMCN59"+"&fdYear="+year+"&fdMonth="+month+"&fdDepartmentId="+fdDepartmentId;
		efform.setStatus(0, "正在加载...");
	}
	else if(index ==9)
	{ 
		var frame = frames[9];
		frame.src = "DispatchAction.do?efFormEname=ZMCN5A"+"&fdYear="+year+"&fdMonth="+month+"&fdDepartmentId="+fdDepartmentId;
		efform.setStatus(0, "正在加载...");
	}
	else if(index ==10)
	{ 
		var frame = frames[10];
		frame.src = "DispatchAction.do?efFormEname=ZMCN5B"+"&fdYear="+year+"&fdMonth="+month+"&fdDepartmentId="+fdDepartmentId;
		efform.setStatus(0, "正在加载...");
	}
	
}
/*报表打印*/
button_print_onclick = function() {
	// 取报表参数
    var fdYear=$("#inqu_status-0-fdYear").val();
	var fdMonth=$("#inqu_status-0-fdMonth").val();
	var fdDepartmentId=$("#inqu_status-0-fdDepartmentId").val();//选择的单位id
	var departmentCode=$("#inqu_status-0-departmentCode").val();//登录人单位id，主要是用来判断打印的是分站报表还是公司报表
	var departmentName = $("#inqu_status-0-departmentName").val();
//	alert(departmentName);
	var param = [];
	param.nowyear =fdYear;
	param.beforeyear=fdYear-1;
	param.nowmonth=fdMonth;
	param.nowyearmonth=fdYear+"-"+fdMonth;
	param.beforeyearmonth=(fdYear-1)+"-"+fdMonth;
	
	var reportEname = "ZM_CN_GSMZBB";
	if(departmentCode=="D.1022303" || departmentCode=="D.1022304" || departmentCode=="D.1022305"){
		//分站登录，除中心站外，只能看分站报表
		reportEname="ZM_CN_FZMZBB";
		param.fddepartmentid = departmentCode;
		param.department = departmentName;
	}
	try {
		previewReport(reportEname,param);
	} catch (e) {
		alert("控件加载失败，请确认控件是否正确安装并将本网站设为信任地址");
	}
}
